﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Forms;

namespace cmdeditor
{
    public partial class EditorMain : Form
    {
        NewCha newChaWin;

        public EditorMain()
        {
            InitializeComponent();
            newChaWin = new NewCha(this);
            
        }


        public void TreeAddNewCha(string ChaName)
        {
            TreeNode NewCha = new TreeNode(ChaName);
            NewCha.ContextMenuStrip = contextMenuCha;
            this.treeChalist.Nodes.Add(NewCha);
            
        }

        public void TreeChaAddNewSkill(TreeNode tnRoot, string SkillName)
        {
            TreeNode NewNode = new TreeNode(SkillName);
            tnRoot.Nodes.Add(NewNode);
            NewNode.ContextMenuStrip = contextMenuSkill;
            tnRoot.EnsureVisible();

        }

        private void buttonNewCha_Click(object sender, EventArgs e)
        {
            newChaWin.Show();
            this.Enabled = false;
        }

        private void treeChalist_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            TreeNode tnSelect = treeChalist.SelectedNode;
            if (tnSelect.Level == 0)
            {
                TreeChaAddNewSkill(tnSelect, "新技能");
            }
            else if (tnSelect.Level == 1)
            {
                MessageBox.Show("1");
            }

        }

        

        private void 修改名字ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode tnSelect = treeChalist.SelectedNode;
            if (tnSelect.Level == 0)
            {
                tnSelect.BeginEdit();

            }

        }

        private void 新建技能ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode tnSelect = treeChalist.SelectedNode;
            if (tnSelect.Level == 0)
            {
                TreeChaAddNewSkill(tnSelect, "新技能");
            }
        }

        private void 修改技能名ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode tnSelect = treeChalist.SelectedNode;
            if (tnSelect.Level == 1)
            {
                tnSelect.BeginEdit();

            }

        }



    }
}
